package teatime.core.model.entity.base;

import java.lang.Comparable;
import java.io.Serializable;


/**
 * This is an object that contains data related to the person table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="person"
 */

public abstract class BasePerson  implements Comparable, Serializable {

	public static String REF = "Person";
	public static String PROP_PERSON_BIRTHDAY = "PersonBirthday";
	public static String PROP_PERSON_SEX = "PersonSex";
	public static String PROP_PERSON_FIRST_NAME = "PersonFirstName";
	public static String PROP_PERSON_CREATE_ACCOUNT = "PersonCreateAccount";
	public static String PROP_ID = "Id";
	public static String PROP_PERSON_CREATE_DATE = "PersonCreateDate";
	public static String PROP_PERSON_SECONDE_NAME = "PersonSecondeName";


	// constructors
	public BasePerson () {
		initialize();
	}

	/**
	 * Constructor for primary key
	 */
	public BasePerson (java.lang.Integer id) {
		this.setId(id);
		initialize();
	}

	/**
	 * Constructor for required fields
	 */
	public BasePerson (
		java.lang.Integer id,
		teatime.core.model.entity.Account personCreateAccount,
		java.lang.String personFirstName,
		java.lang.String personSecondeName,
		java.util.Date personBirthday,
		java.lang.String personSex,
		java.util.Date personCreateDate) {

		this.setId(id);
		this.setPersonCreateAccount(personCreateAccount);
		this.setPersonFirstName(personFirstName);
		this.setPersonSecondeName(personSecondeName);
		this.setPersonBirthday(personBirthday);
		this.setPersonSex(personSex);
		this.setPersonCreateDate(personCreateDate);
		initialize();
	}

	protected void initialize () {}



	private int hashCode = Integer.MIN_VALUE;

	// primary key
	private java.lang.Integer id;

	// fields
	private java.lang.String personFirstName;
	private java.lang.String personSecondeName;
	private java.util.Date personBirthday;
	private java.lang.String personSex;
	private java.util.Date personCreateDate;

	// many to one
	private teatime.core.model.entity.Account personCreateAccount;

	// collections
	private java.util.Set<teatime.core.model.entity.Account> accounts;



	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="native"
     *  column="PERSON_ID"
     */
	public java.lang.Integer getId () {
		return id;
	}

	/**
	 * Set the unique identifier of this class
	 * @param id the new ID
	 */
	public void setId (java.lang.Integer id) {
		this.id = id;
		this.hashCode = Integer.MIN_VALUE;
	}




	/**
	 * Return the value associated with the column: PERSON_FIRST_NAME
	 */
	public java.lang.String getPersonFirstName () {
		return personFirstName;
	}

	/**
	 * Set the value related to the column: PERSON_FIRST_NAME
	 * @param personFirstName the PERSON_FIRST_NAME value
	 */
	public void setPersonFirstName (java.lang.String personFirstName) {
		this.personFirstName = personFirstName;
	}



	/**
	 * Return the value associated with the column: PERSON_SECONDE_NAME
	 */
	public java.lang.String getPersonSecondeName () {
		return personSecondeName;
	}

	/**
	 * Set the value related to the column: PERSON_SECONDE_NAME
	 * @param personSecondeName the PERSON_SECONDE_NAME value
	 */
	public void setPersonSecondeName (java.lang.String personSecondeName) {
		this.personSecondeName = personSecondeName;
	}



	/**
	 * Return the value associated with the column: PERSON_BIRTHDAY
	 */
	public java.util.Date getPersonBirthday () {
		return personBirthday;
	}

	/**
	 * Set the value related to the column: PERSON_BIRTHDAY
	 * @param personBirthday the PERSON_BIRTHDAY value
	 */
	public void setPersonBirthday (java.util.Date personBirthday) {
		this.personBirthday = personBirthday;
	}



	/**
	 * Return the value associated with the column: PERSON_SEX
	 */
	public java.lang.String getPersonSex () {
		return personSex;
	}

	/**
	 * Set the value related to the column: PERSON_SEX
	 * @param personSex the PERSON_SEX value
	 */
	public void setPersonSex (java.lang.String personSex) {
		this.personSex = personSex;
	}



	/**
	 * Return the value associated with the column: PERSON_CREATE_DATE
	 */
	public java.util.Date getPersonCreateDate () {
		return personCreateDate;
	}

	/**
	 * Set the value related to the column: PERSON_CREATE_DATE
	 * @param personCreateDate the PERSON_CREATE_DATE value
	 */
	public void setPersonCreateDate (java.util.Date personCreateDate) {
		this.personCreateDate = personCreateDate;
	}



	/**
	 * Return the value associated with the column: PERSON_CREATE_ACCOUNT_ID
	 */
	public teatime.core.model.entity.Account getPersonCreateAccount () {
		return personCreateAccount;
	}

	/**
	 * Set the value related to the column: PERSON_CREATE_ACCOUNT_ID
	 * @param personCreateAccount the PERSON_CREATE_ACCOUNT_ID value
	 */
	public void setPersonCreateAccount (teatime.core.model.entity.Account personCreateAccount) {
		this.personCreateAccount = personCreateAccount;
	}



	/**
	 * Return the value associated with the column: Accounts
	 */
	public java.util.Set<teatime.core.model.entity.Account> getAccounts () {
		return accounts;
	}

	/**
	 * Set the value related to the column: Accounts
	 * @param accounts the Accounts value
	 */
	public void setAccounts (java.util.Set<teatime.core.model.entity.Account> accounts) {
		this.accounts = accounts;
	}

	public void addToAccounts (teatime.core.model.entity.Account account) {
		if (null == getAccounts()) setAccounts(new java.util.TreeSet<teatime.core.model.entity.Account>());
		getAccounts().add(account);
	}





	public boolean equals (Object obj) {
		if (null == obj) return false;
		if (!(obj instanceof teatime.core.model.entity.Person)) return false;
		else {
			teatime.core.model.entity.Person person = (teatime.core.model.entity.Person) obj;
			if (null == this.getId() || null == person.getId()) return false;
			else return (this.getId().equals(person.getId()));
		}
	}

	public int hashCode () {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getId()) return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}

	public int compareTo (Object obj) {
		if (obj.hashCode() > hashCode()) return 1;
		else if (obj.hashCode() < hashCode()) return -1;
		else return 0;
	}

	public String toString () {
		return super.toString();
	}


}